package com.way.demo.test;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author lipingwei
 * @create 2023-08-14 22:22
 */
public class MainTest4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        // 超过长度200，返回分割不成功
        if (line.length() > 200) {
            System.out.println(0);
        }

        StringBuilder sb = new StringBuilder();
      //  List<String> strings = new ArrayList<>();
        MyArrayList<String> strings = new  MyArrayList();
        char[] chars = line.toCharArray();
        System.out.println("chars:" + Arrays.toString(chars));
        digui(chars, sb, strings, 0);

        // 分割成功且分割结果不唯一则返回-1
        if (strings.size() > 1) {
            System.out.println(strings);
            System.out.println(-1);
        }
        // 分割结果唯一打印分割的子串个数
        if (strings.size() == 1) {
            System.out.println(strings);
            System.out.println(strings.get(0).split(" ").length);
        }
        // 分割不成功则返回 0
        if (strings.size() == 0) {
            System.out.println(0);
        }
    }

    public static void digui(char[] chars, StringBuilder sb, MyArrayList<String> strings, int startIndex) {
        int num = 0;
        StringBuilder sb_temp = new StringBuilder();
        for (int i = startIndex; i < chars.length; i++) {
            char aChar = chars[i];
            num += aChar;
            sb_temp.append(aChar);

            if (!isNar(num)) {
                continue;
            }

            StringBuilder sb_copy = new StringBuilder(sb);
            sb_copy.append(sb_temp).append(" ");

            if (i == chars.length - 1) {
                strings.add(sb_copy.toString().trim());
                return;
            }

            digui(chars, sb_copy, strings, i + 1);
        }
    }

    // 判断是否是水仙花数
    public static boolean isNar(int num) {
        if (num < 100 || num > 999) return false;
        int bai = num / 100;
        int shi = (num % 100) / 10;
        int ge = (num % 100) % 10;
        // Math.pow(底数x,指数y)
        int v = (int) (Math.pow(bai, 3) + Math.pow(shi, 3) + Math.pow(ge, 3));
        return v == num;
    }

    //集合
    public static  class MyArrayList<E>{
        private Object[] array = new Object[0];   //默认长度为0
        private int size; //记录数据

        public void add(E data) {
            //定义新数组
            Object[] newArr = new Object[array.length+1];
            //复制原数组的数据

            //保存数据
            newArr[array.length] = data;
            //更新数组
            array = newArr;
            size++;
        }



        public E get(int index) {
            return (E)array[index];
        }

        public int size() {
            return 0;
        }

    }





}
